<?php 

include '../function.php';

$mysqli = @new mysqli("127.0.0.1", "root", "", "school");


if($mysqli->connect_errno){
	exit("数据链接失败：原因：".$mysqli->connect_errno.":".$mysqli->connect_error);
}

$mysqli->query("set names utf8");



$stmt = $mysqli->prepare("insert into stu (name,age) values(?,?)");



$time1 = microtime(true);

if($stmt){


	$stmt->bind_param('si',$name, $age);

	for ($i=0; $i <1000 ; $i++) { 
		
		$name = "小明".$i;

		$age = $i;

		$stmt->execute();
	}

}

echo microtime(true)-$time1;




exit;






$time1 = microtime(true);

echo $time1 ."<br>";

for ($i=0; $i <1000 ; $i++) { 

	$sql = "insert into stu (name,age) values('小明".$i."',".$i.")";
	$res = $mysqli->query($sql);
	
}

echo microtime(true)-$time1;

























 ?>